#ifndef SDMS_FILTER_H
#define SDMS_FILTER_H
#include "documents.h"
#include <iostream>
#include <string>

namespace sdms
{
using namespace std;
//重载操作符
//&&: Filter的and操作
//||：Filter的or操作
//!：Filter的not操作
class documents;
class Filter
{
public:
    Filter():id(0) {}
    Filter(documents* s):id(0)
    {
        set_documents(s);
    }
    virtual ~Filter() {}
    friend Filter operator&&(const Filter& lf,const Filter& rf);
    friend Filter operator||(const Filter& lf,const Filter& rf);
    bool operator==(const Filter& rf);
    Filter& operator=(const Filter&rf);
    virtual string tostring() const;
    virtual void eval() {}
    virtual void set_documents(documents* s)
    {
        doc=s;
    }
    virtual void set_name(const string&);
    virtual void set_id(const unsigned int id);
    virtual unsigned int get_id() const;
    virtual string get_sql() const;
    virtual string get_name() const;
    virtual bool empty();
    virtual void clear();

protected:
    string sql;
    documents* doc;
    vector<unsigned int> docid;

    unsigned int id;
    string name;
};
class WritingFilter: public Filter
{
public:
    WritingFilter()
    {
        id=0;
    }
    WritingFilter(documents* s)
    {
        id=0;
        set_documents(s);
    }
    virtual ~WritingFilter() {}
    virtual void eval();
};
class AbstractFilter: public Filter
{
public:
    AbstractFilter()
    {
        id=0;
    }
    AbstractFilter(documents* s)
    {
        id=0;
        set_documents(s);
    }
    virtual ~AbstractFilter() {}
    virtual void eval();
};
class categoryfilter:public Filter
{
public:
    categoryfilter()
    {
        id=0;
    }
    categoryfilter(documents* s)
    {
        id=0;
        set_documents(s);
    }
    virtual ~categoryfilter() {}
    virtual void eval();
};
class PublisherFilter:public Filter
{
public:
    PublisherFilter()
    {
        id=0;
    }
    PublisherFilter(documents* s)
    {
        id=0;
        set_documents(s);
    }
    virtual ~PublisherFilter() {}
    virtual void eval();
};
class NoPublisherFilter:public Filter
{
public:
    NoPublisherFilter()
    {
        id=0;
    }
    virtual ~NoPublisherFilter() {}
    virtual void eval();
};

//has not been reading
class NotReading:public Filter
{
public:
    NotReading()
    {
        id=0;
    }
    virtual ~NotReading() {}
    virtual void eval();
};
class NoTagFilter:public Filter
{
public:
    NoTagFilter()
    {
        id=0;
    }
    virtual ~NoTagFilter() {}
    virtual void eval();
};
class TagFilter:public Filter
{
public:
    TagFilter()
    {
        id=0;
    }
    TagFilter(documents* s)
    {
        id=0;
        set_documents(s);
    }
    virtual ~TagFilter() {}
    virtual void eval();
};
class DocumentFilter:public Filter
{
public:
    DocumentFilter()
    {
        id=0;
    }
    virtual ~DocumentFilter() {}
    virtual void eval();
};
class ReadingFilter:public Filter
{
public:
    ReadingFilter()
    {
        id=0;
    }
    virtual ~ReadingFilter() {}
    virtual void eval();
};
};
#endif
